package com.tssup.fesco.ofc;

import com.tssup.fesco.service.SchedulService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
import com.xxl.job.core.log.XxlJobLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by haomin on 2017/3/28.
 * 用于将b2c订单初始化到ofc
 */
@JobHander(value="OrderInitJob")
@Service
public class OrderInitJob extends IJobHandler {

    private Logger logger =  LoggerFactory.getLogger(this.getClass());

    @Autowired
    SchedulService schedulService;

    /**
     * 每30秒执行一次
     */
    @Override
    public ReturnT<String> execute(String... strings) throws Exception {
        try {
            XxlJobLogger.log("初始化订单定时任务开始");
            schedulService.createOfcOrderProcess();
            XxlJobLogger.log("初始化订单定时任务正常结束");
        }catch ( Exception e ){
            logger.error("初始化订单定时任务异常结束", e);
            XxlJobLogger.log("初始化订单定时任务异常结束");
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
